import http from '@/api/index.js'

/* 添加说说 */
const addshuoshuo =(data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/addshuoshuo",data).then(res =>{
            resolve(res)
        })
    })
}
/* 上传说说图片名字 */
const uploadshuoshuoimg = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/uploadshuoshuoimg",data).then(res =>{
            resolve(res)
        })
    })
}
/* 分页获取说说时间降序 */
const getshuoshuo = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/getshuoshuo",data).then(res =>{
            resolve(res)
        })
    })
}
/* 获取置顶说说 */
const gettopshuoshuo = ()=>{
    return new Promise((resolve, reject) => {
        http.get("/api/shuoshuo/gettopshuoshuo").then(res =>{
            resolve(res)
        })
    })
}
/* 获取说说 */
const apigetshuoshuoByid = (id)=>{
    return new Promise((resolve, reject) => {
        http.get("/api/shuoshuo/getshuoshuobyid",{
            params:{
                id:id
            }
        }).then(res =>{
            resolve(res)
        })  
    })
}
/* 编辑说说 */
const editshuoshuo = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/editshuoshuo",data).then(res =>{
            resolve(res)
        })
    })
} 
/* 修改说说对应的图片 */
const updatashuoshuoimg = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/updatashuoshuoimg",data).then(res =>{
            resolve(res)
        })
    })
}
/* 修改封面 */
const updatacover = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/updatacover",data).then(res =>{
            resolve(res)    
        })
    })
}
/* 校验能否置顶 */
const cantop =()=>{
    return new Promise((resolve, reject) => {
        http.get("/api/shuoshuo/cantop").then(res =>{
            resolve(res)
        })
    })
}
/* 置顶和取消置顶说说 */
const totop =(data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/updatatop",data).then(res =>{
            resolve(res)
        })
    })
}
/* 修改是否公开 */
const tovisible = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/tovisible",data).then(res =>{
            resolve(res)
        })
    })
}
/* 删除说说 */
const todelete = (data)=>{
    return new Promise((resolve, reject) => {
        http.post("/api/shuoshuo/todelete",data).then(res =>{
            resolve(res)
        })
    })
}
export {
    totop,
    addshuoshuo,
    uploadshuoshuoimg,
    getshuoshuo,
    gettopshuoshuo,
    apigetshuoshuoByid,
    editshuoshuo,
    updatashuoshuoimg,
    updatacover,
    cantop,
    tovisible,
    todelete
}